import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../views/home.vue'
import product from '../views/product.vue'
import equipment from '../views/equipment.vue'
import order from '../views/order.vue'
import plan from '../views/plan.vue'
import scheduling from '../views/scheduling.vue'
import tracking from '../views/tracking.vue'
import login from '../views/login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: home
  },
  {
    path: '/product',
    name: 'product',
    component: product
  },
  {
    path: '/equipment',
    name: 'equipment',
    component: equipment
  },
  {
    path: '/order',
    name: 'order',
    component: order
  },
  {
    path: '/plan',
    name: 'plan',
    component: plan
  },
  {
    path: '/scheduling',
    name: 'scheduling',
    component: scheduling
  },
  {
    path: '/tracking',
    name: 'tracking',
    component: tracking
  },
  {
    path: '/',
    name: 'login',
    component: login
  },
]

//解决重复路由报异常问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

export default router
